package com.weixiaodong.ModelDesign.生成实例.Prototype模式.复制模式实例演示;

@SuppressWarnings("all")
public class MessageBox implements Product {

    private char decochar;

    public MessageBox(char decochar) {
        this.decochar = decochar;
    }

    @Override
    public void use(String s) {
        for (int i = 0; i < s.length(); i++) {
            System.out.print(decochar);
        }

        System.out.println();
        System.out.println(s);

        for (int i = 0; i < s.length(); i++) {
            System.out.print(decochar);
        }
    }

    @Override
    public Product createClone() {
        Product p = null;
        try {
            p = (Product) clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }

        return p;
    }
}
